package com.study.edoc.config;

import com.google.common.base.Predicates;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {


    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("电子文档Restful API接口文档")
                .description("SpringBoot集成Swagger生成API接口文档")
                .contact(
                        new Contact("刘垛生","http://www.hfjava.cn","290982492@qq.com")
                )
                .version("v1.0")
                .termsOfServiceUrl("http://www.hfjava.cn")
                .build();
    }

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("电子文档管理系统API接口")
                .apiInfo(apiInfo())//创建该Api的基本信息
                .select()//控制哪些接口暴露给Swagger ui来展现
                .apis(RequestHandlerSelectors.basePackage("com.study.edoc.controller")) //指定需要扫描的包路路径
                .paths(PathSelectors.any())
                //.paths(Predicates.or(PathSelectors.regex("/api/.*")))//过滤的接口
                .build();
    }
}
